namespace Microsoft.Robotics.Core.Algorithms.UnitTests
{
    using System;
    using Microsoft.Robotics.Core.Algorithms;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// The PID Controller unit test class.
    /// </summary>
    [TestClass]
    public class ThrottlingTests
    {
        /// <summary>
        /// Test if CallsAreThrottledWhenScalingIsSpecified
        /// </summary>
        [TestMethod]
        [TestCategory("Unit")]
        public void CallsAreThrottledWhenScalingIsSpecified()
        {
            // downscale width and depth by the factor of 2, leave frequency unchanged
            FrequencyThrottler throttle = new FrequencyThrottler(3);

            Assert.IsFalse(throttle.Throttle()); // first frame must be skipped            
            Assert.IsFalse(throttle.Throttle()); // second frame must be skipped            
            Assert.IsTrue(throttle.Throttle()); // third frame must NOT be skipped            

            // repeat
            Assert.IsFalse(throttle.Throttle()); // first frame must be skipped            
            Assert.IsFalse(throttle.Throttle()); // second frame must be skipped            
            Assert.IsTrue(throttle.Throttle()); // third frame must NOT be skipped       
        }
    }
}
